<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <canvas width="600px" height="600px">

    </canvas>
    <script>
        const canvas = document.querySelector("canvas");
        
        const ctx = canvas.getContext("2d");
          /**
        *   canvas 画折线的步骤：
        *       1. 把 画笔移动到起点 moveTo(x,y);
        *       2. 确定 转折点1 lineTo(x,y);  
        *       3. 确定 转折点2 lineTo(x,y); 
        *       4. 确定 转折点n...
        *       5. 画线 stroke();
        * */
    
       ctx.moveTo(100,100);
       ctx.lineTo(100,300);
       ctx.lineTo(300,300);
       ctx.lineTo(300,100);
       ctx.stroke();
       

    </script>
</body>
</html>